package com.tvunetworks.device.extra.controller;

import com.tvunetworks.center.common.util.Result;
import com.tvunetworks.center.common.util.ResultUtil;
import com.tvunetworks.device.extra.service.RegionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author liam
 */
@RestController
@RequestMapping("region")
@Slf4j
public class RegionController {

    @Autowired
    private RegionService regionService;

    /**
     * 根据IP获取region
     * @param request 请求
     * @param imageType imageType
     * @return region
     */
    @GetMapping("default")
    public Result defaultRegionByIP(HttpServletRequest request, @RequestParam String imageType) {
        return ResultUtil.success(regionService.defaultRegionByIp(request, imageType));
    }
}
